/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.bm.model;

/**
 *
 * @author IT
 */
public class BaseMessage implements IMessage {

    private static final long serialVersionUID = -6706581775019584070L;
    /**
     * Holds the actual message values. Must be instantiated within each
     * subclass's constructor.
     */
    protected String[] data = null;

    /**
     * @see com.bm.fmss.model.IMessage#setItem(int, java.lang.String)
     */
    @Override
    public void setItem(int key, String value) {
        if (null != data && data.length > key) {
            data[key] = value;
        }
    }

    /**
     * @see com.bm.fmss.model.IMessage#getItem(int)
     */
    @Override
    public String getItem(int key) {
        if (null != data && data.length > key) {
            return data[key];
        }
        return null;
    }

    /**
     * @see java.lang.Object#toString()
     */
    @Override
    public String toString() {
        StringBuffer s = new StringBuffer();
        if (null != data) {
            for (int i = 0; i < data.length; i++) {
                if (i > 0) {
                    s.append(DELIMETER);
                }
                if (null != getItem(i)) {
                    s.append(getItem(i));
                }
            }
        }
        return s.toString();
    }
}
